TEACHINGBEGIN="2022-8-29"
from datetime import date, datetime
def show_TeachingPeriod(now_date : str, begin_date : str=TEACHINGBEGIN):
    '''显示当前日期是第几周(教学周)
    输入： 当前日期 str xxxx-xx-xx
           教学周第一周的第一天  str xxxx-xx-xx
    
    输出：第几周  str
    '''
    nowtime=datetime(int(now_date.split("-")[0]), int(now_date.split("-")[1]), int(now_date.split("-")[2]))
    begintime=datetime(int(begin_date.split("-")[0]), int(begin_date.split("-")[1]), int(begin_date.split("-")[2]))
    dis=date_distance(begin_date, now_date)
    week_num=(dis//7)+1
    return " 第"+str(week_num)+"周" 
    # print(nowtime.weekday())
    # print(begintime.weekday())
    pass


def date_distance(date1 : str, date2 : str):
    '''计算两个日期相差多少天。用于教学周和倒计时。
    输入： 日期1  str xxxx-xx-xx
           日期2  str xxxx-xx-xx
    
    输出：几（天）  int
    如果是后面晚 就是返回一个正数

    '''
    if date1 == date2:
        return 0
    datetime1=datetime(int(date1.split("-")[0]), int(date1.split("-")[1]), int(date1.split("-")[2]))
    datetime2=datetime(int(date2.split("-")[0]), int(date2.split("-")[1]), int(date2.split("-")[2]))
    # return (str(datetime2.__sub__(datetime1)))
    return int(str(datetime2.__sub__(datetime1)).split(" ")[0])
    pass

# print(show_TeachingPeriod("2022-10-26","2022-10-3"))